//
//  BWFVisitorViewController.swift
//  网易新闻项目
//
//  Created by 薄文飞 on 16/3/5.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class BWFVisitorViewController: UITableViewController {

    let userLogon :Bool = false
    
    override func loadView() {
        
        if userLogon == true {
        
            super.loadView()

        } else {
            
            setUpView()
        
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    //如果没有登录，加载登录界面
  private func setUpView() {
    
    view = visitorView
    navigationItem.leftBarButtonItem = UIBarButtonItem(titel: "注册", target: self, action: "login")
    navigationItem.rightBarButtonItem = UIBarButtonItem(titel: "登录", target: self, action: "login")

    }
    
    func login() {
    
        let vc = BWFLoginViewController()
        presentViewController(BWFNavigationController(rootViewController: vc), animated: true, completion: nil)
        
    }
    
    //懒加载访客View
    lazy var visitorView :BWFVisitorView = {
    
        let visitorView = BWFVisitorView()
        visitorView.callBack = {
        
            self.login()
            
        }
        return visitorView
    }()
}
